package com.hkemmm.control;

import com.hkemmm.bean.UserInfoBean;
import com.hkemmm.service.ILoginService;
import com.hkemmm.service.IMovable;
import com.hkemmm.service.impl.Bus;
import org.springframework.stereotype.Controller;

import javax.annotation.Resource;

@Controller("test")
public class TestControl {

    /*
    因为JDK动态代理只能针对接口，所以你要么把AutoWired中的东西改成接口，要么在你的配置文件中，找到：
    <tx:annotation-driven transaction-manager="transactionManager"/>
    在它中间加入 proxy-target-class="true"  最后就可以了。

    如果用类去接收注入将会报错
    * */
    @Resource(name = "loginService")
    ILoginService loginService;
    @Resource(name = "car")
    IMovable movable;
    @Resource(name = "bus")
    IMovable bus;
    @Resource
    UserInfoBean userInfoBean;

    public void move() {
        movable.moving();

        System.out.println("--------------move------------");
        bus.moving();
    }


    public boolean doLogin() {
        boolean can = false;
        can = loginService.doLogin(userInfoBean);

        return can;
    }


    public ILoginService getLoginService() {
        return loginService;
    }

    public void setLoginService(ILoginService loginService) {
        this.loginService = loginService;
    }

    public IMovable getMovable() {
        return movable;
    }

    public void setMovable(IMovable movable) {
        this.movable = movable;
    }

    public IMovable getBus() {
        return bus;
    }

    public void setBus(IMovable bus) {
        this.bus = bus;
    }

    public UserInfoBean getUserInfoBean() {
        return userInfoBean;
    }

    public void setUserInfoBean(UserInfoBean userInfoBean) {
        this.userInfoBean = userInfoBean;
    }
}
